import { _decorator, Component, Node, director, game} from 'cc';
const { ccclass, property } = _decorator;



@ccclass('btnEvent')
export class btnEvent extends Component {
    @property(Node)
    public ProgressBar:Node = null;

    @property
    private isLoaded = false;
    start() {
        director.preloadScene("game",(ccnt:number,tcnt:number,item )=>{
            let progress = ccnt/tcnt;
            console.log("加载进度："+Math.floor(progress*100)+"%");
            this.ProgressBar.active = true;
            this.ProgressBar.progress = progress;
        },(err:Error)=>{
            this.isLoaded = true;
        })
    }

    // update(deltaTime: number) {
        
    // }
    
    btnClickHandler(){
        if(this.isLoaded){
            director.loadScene("game",()=>{
                console.log("已经进入游戏界面，并加载完成");
            });
        }
        
    }
    
    changeScene(){
        director.loadScene("game");
        game.addPersistRootNode(this.dataStore)
    }

}


